﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="DataEmployee.aspx.cs" Inherits="UdrinkWater_Project.Admin.DataEmployee" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script type="text/javascript">
    // <![CDATA[
         function ShowLoginWindow() {
             pcLogin.Show();
         }
    // ]]> 
    </script>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Font-Size="Medium" 
        HeaderText="ข้อมูลพนักงาน" Width="100%">
        <HeaderStyle HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
    <dx:ASPxButton ID="bt_AddEmp" runat="server" Text="เพิ่มพนักงาน" 
        OnClick="bt_AddEmp_Click">
    </dx:ASPxButton>
    <dx:ASPxGridView ID="GV_ShowdataEmp" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource_DataEmp" Font-Size="Small" KeyFieldName="ID_Card" 
        Width="100%" EnableCallBacks="False" 
        OnRowCommand="GV_ShowdataEmp_RowCommand">
        <Columns>
            <dx:GridViewDataTextColumn FieldName="ID_Card" ReadOnly="True" 
                ShowInCustomizationForm="True" VisibleIndex="1" Caption="รหัสพนักงาน">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Prefix" ShowInCustomizationForm="True" 
                VisibleIndex="2" Caption="คำนำหน้าชื่อ">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Firstname" ShowInCustomizationForm="True" 
                VisibleIndex="3" Caption="ชื่อ">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Lastname" ShowInCustomizationForm="True" 
                VisibleIndex="4" Caption="นามสกุล">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn FieldName="Department_ID" 
                ShowInCustomizationForm="True" VisibleIndex="5" Caption="ตำแหน่ง">
                <PropertiesComboBox DataSourceID="Sql_Department" TextField="Department_Name" 
                    ValueField="Department_ID" ValueType="System.Int32">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="Address" 
                ShowInCustomizationForm="True" VisibleIndex="6" Caption="ที่อยู่">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn FieldName="DISTRICT_ID" 
                ShowInCustomizationForm="True" VisibleIndex="7" Caption="ตำบล">
                <PropertiesComboBox DataSourceID="SqlDataDistrict" TextField="DISTRICT_NAME" 
                    ValueField="DISTRICT_ID" ValueType="System.Int32">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataComboBoxColumn FieldName="AMPHUR_ID" 
                ShowInCustomizationForm="True" VisibleIndex="8" Caption="อำเภอ">
                <PropertiesComboBox DataSourceID="SqlDataAumphur" TextField="AMPHUR_NAME" 
                    ValueField="AMPHUR_ID" ValueType="System.Int32">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataComboBoxColumn FieldName="PROVINCE_ID" 
                ShowInCustomizationForm="True" VisibleIndex="9" Caption="จังหวัด">
                <PropertiesComboBox DataSourceID="SqlDataProvince" TextField="PROVINCE_NAME" 
                    ValueField="PROVINCE_ID" ValueType="System.Int32">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="Tel" 
                ShowInCustomizationForm="True" VisibleIndex="10" Caption="เบอร์โทรศัพท์">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Salary" ShowInCustomizationForm="True" 
                VisibleIndex="11" Caption="เงินเดือน">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataDateColumn FieldName="StartJob" ShowInCustomizationForm="True" 
                VisibleIndex="12" Caption="วันเริ่มงาน">
                <PropertiesDateEdit DisplayFormatString="dd MMMM yyyy">
                </PropertiesDateEdit>
            </dx:GridViewDataDateColumn>
            <dx:GridViewDataTextColumn ShowInCustomizationForm="True" VisibleIndex="13">
                <DataItemTemplate>
                    <asp:LinkButton ID="link_Edit" runat="server" CommandName="Cmd_Edit" CommandArgument='<%# Eval("ID_Card") %>'>แก้ไข
                    </asp:LinkButton>
                    &nbsp;
                    <asp:LinkButton ID="link_Delete" runat="server" OnClientClick = " return confirm('ยืนยันการลบข้อมูล');"
                        CommandArgument='<%# Eval("ID_Card") %>' CommandName="Cmd_Delete">ลบข้อมูล     </asp:LinkButton>
                </DataItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsBehavior ConfirmDelete="True" />
        <SettingsPager Mode="ShowAllRecords">
        </SettingsPager>
        <SettingsText ConfirmDelete="ยืนยันการลบข้อมูล" />
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataSource_DataEmp" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT * FROM [TB_Employee]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="Sql_Department" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT * FROM [TB_Department]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataProvince" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT * FROM [TB_Province]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataAumphur" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT * FROM [TB_Aumphur]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataDistrict" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT * FROM [TB_District]"></asp:SqlDataSource>
            </dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
    <dx:ASPxPopupControl ID="pcLogin" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcLogin"
        HeaderText="แก้ไขข้อมูล" AllowDragging="True" PopupAnimationType="None" 
         EnableViewState="False" Font-Size="Medium" Width="344px">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent1" runat="server">
                            <table>
                                <tr>
                                    <td rowspan="12">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                    <td class="pcmCellCaption" align="right" style="font-size: medium">
                                        คำนำหน้าชื่อ :</td>
                                    <td class="pcmCellText">
                                        <dx:ASPxTextBox ID="tbprefix" runat="server" Width="150px" 
                                            ClientInstanceName="tbLogin">
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td rowspan="12">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pcmCellCaption" align="right" style="font-size: medium" >
                                        ชื่อ :</td>
                                    <td class="pcmCellText">
                                        <dx:ASPxTextBox ID="tbname" runat="server" Width="150px">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        นามสกุล :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxTextBox ID="tblname" runat="server" Width="150px">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        ตำแหน่ง :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxComboBox ID="comb_department" runat="server" 
                                            DataSourceID="Sql_Department1" TextField="Department_Name" 
                                            ValueField="Department_ID" ValueType="System.Int32">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="Sql_Department1" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            SelectCommand="SELECT * FROM [TB_Department]"></asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        ที่อยู่ :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxTextBox ID="tbaddress" runat="server" Width="150px">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        จังหวัด :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxComboBox ID="comb_province" runat="server" DataSourceID="Sql_Province" 
                                            TextField="PROVINCE_NAME" ValueField="PROVINCE_ID" 
                                            ValueType="System.Int32" AutoPostBack="True">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="Sql_Province" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            SelectCommand="SELECT * FROM [TB_Province]"></asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        อำเภอ :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxComboBox ID="comb_aumphur" runat="server" DataSourceID="Sql_Aumphur" 
                                            TextField="AMPHUR_NAME" ValueField="AMPHUR_ID" ValueType="System.Int32" 
                                            AutoPostBack="True">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="Sql_Aumphur" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            
                                            SelectCommand="SELECT * FROM [TB_Aumphur] WHERE ([PROVINCE_ID] = @PROVINCE_ID)">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="comb_province" Name="PROVINCE_ID" 
                                                    PropertyName="Value" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        ตำบล :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxComboBox ID="comb_district" runat="server" DataSourceID="Sql_District" 
                                            TextField="DISTRICT_NAME" ValueField="DISTRICT_ID" ValueType="System.Int32">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="Sql_District" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            
                                            SelectCommand="SELECT * FROM [TB_District] WHERE ([AMPHUR_ID] = @AMPHUR_ID)">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="comb_aumphur" Name="AMPHUR_ID" 
                                                    PropertyName="Value" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        เบอร์โทรศัพท์ :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxTextBox ID="tbtel" runat="server" Width="150px">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        เงินเดือน :</td>
                                    <td class="pcmCheckBox">
                                        <dx:ASPxTextBox ID="tbsalary" runat="server" Width="150px">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="font-size: medium">
                                        &nbsp;</td>
                                    <td class="pcmCheckBox">
                                        <table style="width: 100%">
                                            <tr>
                                                <td>
                                                    <dx:ASPxButton ID="btOK" runat="server" 
                                                        style="float: left; margin-right: 8px" Text="ตกลง" Width="80px" 
                                                        Font-Size="Medium" OnClick="btOK_Click">
                                                        <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) pcLogin.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                                <td>
                                                    <dx:ASPxButton ID="btCancel" runat="server" AutoPostBack="False" 
                                                        style="float: left; margin-right: 8px" Text="ยกเลิก" Width="80px" 
                                                        Font-Size="Medium">
                                                        <ClientSideEvents Click="function(s, e) { pcLogin.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <div class="pcmButton">
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <div>
                    &nbsp;</div>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ContentStyle>
            <Paddings PaddingBottom="5px" />
        </ContentStyle>
    </dx:ASPxPopupControl>
</asp:Content>
